namespace CollabApp.Domain.ValueObjects
{
    /// <summary>
    /// 道具值对象
    /// </summary>
    public class PowerUp
    {
        public PowerUpType Type { get; private set; }
        public Position Position { get; private set; }
        public DateTime CreatedAt { get; private set; }
        public TimeSpan Duration { get; private set; }
        public bool IsUsed { get; private set; }

        public PowerUp(PowerUpType type, Position position, TimeSpan duration)
        {
            Type = type;
            Position = position;
            Duration = duration;
            CreatedAt = DateTime.UtcNow;
            IsUsed = false;
        }

        /// <summary>
        /// 使用道具
        /// </summary>
        public void Use()
        {
            IsUsed = true;
        }

        /// <summary>
        /// 获取道具描述
        /// </summary>
        /// <returns>道具描述</returns>
        public string GetDescription()
        {
            return Type switch
            {
                PowerUpType.Lightning => "闪电道具：移动速度提升60%，持续8秒",
                PowerUpType.Shield => "护盾道具：免疫一次截断攻击，持续12秒",
                PowerUpType.Bomb => "炸弹道具：在当前位置创造领地，半径30像素",
                PowerUpType.Ghost => "幽灵道具：10秒内穿越敌方轨迹不死亡，但不能圈地",
                _ => "未知道具"
            };
        }

        /// <summary>
        /// 获取道具颜色
        /// </summary>
        /// <returns>道具颜色</returns>
        public string GetColor()
        {
            return Type switch
            {
                PowerUpType.Lightning => "#0066FF", // 蓝色
                PowerUpType.Shield => "#FFD700", // 金色
                PowerUpType.Bomb => "#FF0000", // 红色
                PowerUpType.Ghost => "#8A2BE2", // 紫色
                _ => "#FFFFFF"
            };
        }

        /// <summary>
        /// 获取道具图标
        /// </summary>
        /// <returns>道具图标字符</returns>
        public string GetIcon()
        {
            return Type switch
            {
                PowerUpType.Lightning => "⚡",
                PowerUpType.Shield => "🛡️",
                PowerUpType.Bomb => "💣",
                PowerUpType.Ghost => "👻",
                _ => "❓"
            };
        }

        /// <summary>
        /// 检查道具是否可以在指定区域使用
        /// </summary>
        /// <param name="playerPosition">玩家位置</param>
        /// <param name="isInEnemyTerritory">是否在敌方领地</param>
        /// <returns>是否可以使用</returns>
        public bool CanUseAt(Position playerPosition, bool isInEnemyTerritory)
        {
            return Type switch
            {
                PowerUpType.Bomb => !isInEnemyTerritory, // 炸弹只能在中立区域或己方领地使用
                _ => true
            };
        }
    }

    /// <summary>
    /// 道具类型枚举
    /// </summary>
    public enum PowerUpType
    {
        /// <summary>
        /// 闪电道具 - 移动速度提升
        /// </summary>
        Lightning,

        /// <summary>
        /// 护盾道具 - 免疫截断攻击
        /// </summary>
        Shield,

        /// <summary>
        /// 炸弹道具 - 创造领地
        /// </summary>
        Bomb,

        /// <summary>
        /// 幽灵道具 - 穿越敌方轨迹
        /// </summary>
        Ghost
    }
}